Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

solution #39

wants to merge 2 commits into from

Conversation

PozniakVA
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on implementing the core functionalities! 🎉 While there are some areas for improvement, such as enhancing error handling, validation, and ensuring compatibility with different Python versions, these are minor and don't impact the core functionality. Keep up the good work and consider the feedback for future enhancements! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

@@ -5,7 +5,7 @@ services:
env_file:
- .env
ports:
- "5432:5432"
- "5433:5432"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The port mapping for the db service is set to 5433:5432. Ensure that port 5433 is the intended external port for PostgreSQL, as the default PostgreSQL port is 5432. If you don't have a specific reason to change it, consider using 5432:5432.



def get_movies(db: Session, offset, per_page):
return db.query(MovieModel).order_by(MovieModel.id.desc()).offset(offset).limit(per_page).all()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding validation for the offset and per_page parameters to ensure they are non-negative integers. This will prevent potential errors when querying the database.

return db.query(MovieModel).order_by(MovieModel.id.desc()).offset(offset).limit(per_page).all()


def get_movie(db: Session, movie_id):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The movie_id parameter should be validated to ensure it is a positive integer. This will help avoid unnecessary database queries for invalid IDs.

db.refresh(db_movie)
return db_movie

except SQLAlchemyError:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching SQLAlchemyError is good for handling database errors, but consider logging the exception details for easier debugging and monitoring.

@router.patch("/movies/{movie_id}/")
def patch_movie(movie_id: int, movie: MovieUpdateSchema, db: Session = Depends(get_db)):
update_movie(db, movie_id, movie)
return HTTPException(status_code=200, detail="Movie updated successfully.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch_movie function returns an HTTPException instead of a response object. Consider returning a response with a status code and message instead of raising an exception for successful updates.

class CountrySchema(BaseModel):
id: int
code: str
name: str | None

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type hint for name in CountrySchema uses the syntax str | None, which is valid in Python 3.10 and later. Ensure that your environment supports this syntax, or use Optional[str] for compatibility with earlier Python versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants